// Date: 2021/11/5 15:22

var twoSum = function(nums, target) {

    let hash = {};
    for (let i = 0; i < nums.length; i++) {
        let r = target - nums[i];
        if (hash[r] !== undefined) return [hash[r], i];
        hash[nums[i]] = i
    }
    return [-1, -1]
};

function main() {

    console.log(twoSum([2, 7, 11, 15], 9))  // [0, 1]
}

main()